﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Galaktika.BI.Silverlight.Controls.OLAP.Descriptions
{
    public class MemberDescription : DescriptionBase, IPropertiesDescription
    {
        private long m_ChildCount = 0;
        public long ChildCount
        {
            get { return m_ChildCount; }
            set { m_ChildCount = value; }
        }

        private bool m_DrilledDown;
        public bool DrilledDown
        {
            get { return m_DrilledDown; }
            set { m_DrilledDown = value; }
        }

        private int m_LevelDepth = 0;
        public int LevelDepth
        {
            get { return m_LevelDepth; }
            set { m_LevelDepth = value; }
        }

        private String m_LevelName = String.Empty;
        public String LevelName
        {
            get { return m_LevelName; }
            set { m_LevelName = value; }
        }

        private String m_HierarchyUniqueName = String.Empty;
        public String HierarchyUniqueName
        {
            get { return m_HierarchyUniqueName; }
            set { m_HierarchyUniqueName = value; }
        }

        private String m_Custom_Rollup = String.Empty;
        public String Custom_Rollup
        {
            get { return m_Custom_Rollup; }
            set { m_Custom_Rollup = value; }
        }

        private bool m_ParentSameAsPrevious;
        public bool ParentSameAsPrevious
        {
            get { return m_ParentSameAsPrevious; }
            set { m_ParentSameAsPrevious = value; }
        }

        public MemberDescription()
        {
        }

        List<PropertyDescription> m_Properties = null;
        public List<PropertyDescription> Properties
        {
            get {
                if (m_Properties == null)
                {
                    m_Properties = new List<PropertyDescription>();
                    m_Properties.Add(new PropertyDescription("Caption", this.Caption));
                    m_Properties.Add(new PropertyDescription("Name", this.Name));
                    m_Properties.Add(new PropertyDescription("UniqueName", this.UniqueName));
                    m_Properties.Add(new PropertyDescription("ChildCount", this.ChildCount));
                    m_Properties.Add(new PropertyDescription("DrilledDown", this.DrilledDown));
                    m_Properties.Add(new PropertyDescription("Description", this.Description));
                    m_Properties.Add(new PropertyDescription("Custom_Rollup", this.Custom_Rollup));
                    m_Properties.Add(new PropertyDescription("HierarchyUniqueName", this.HierarchyUniqueName));
                    m_Properties.Add(new PropertyDescription("LevelDepth", this.LevelDepth));
                    m_Properties.Add(new PropertyDescription("LevelName", this.LevelName));
                    m_Properties.Add(new PropertyDescription("ParentSameAsPrevious", this.ParentSameAsPrevious));
                }
                return m_Properties;
            }
            set {
                m_Properties = value;
            }
        }

        List<PropertyDescription> m_MemberProperties = null;
        public List<PropertyDescription> MemberProperties
        {
            get
            {
                if (m_MemberProperties == null)
                {
                    m_MemberProperties = new List<PropertyDescription>();
                }
                return m_MemberProperties;
            }
            set
            {
                m_MemberProperties = value;
            }
        }


        #region IPropertiesDescription Members


        public PropertyDescription GetProperty(string name)
        {
            foreach (PropertyDescription prop in Properties)
            {
                if (prop.Name == name)
                    return prop;
            }
            return null;
        }

        public PropertyDescription GetMemberProperty(string name)
        {
            foreach (PropertyDescription prop in MemberProperties)
            {
                if (prop.Name == name)
                    return prop;
            }
            return null;
        }


        #endregion
    }
}
